﻿using System;
using System.Collections.Generic;
using System.Linq;
using VideoSeller.Business.Models;
using VideoSeller.Core.Configuration;

namespace VideoSeller.Web.Models
{
	public class LanguageBarViewModel
	{
		public List<CultureItemViewModel> Cultures { get; set; }

		public LanguageBarViewModel()
		{
			Cultures = new List<CultureItemViewModel>();
		/*	var flags = new Dictionary<string, string>
				{
					{"en-US", "~/Content/images/lang_uk_small.png"},
					{"fr-FR", "~/Content/images/lang_fr_small.png"},
					{"de-DE", "~/Content/images/lang_de_small.png"},
					{"it-IT", "~/Content/images/lang_ita_small.png"},
					{"ru-RU", "~/Content/images/lang_ru_small.png"},
					{"es-ES", "~/Content/images/lang_spn_small.png"},
					{"zh-CN", "~/Content/images/lang_zh_small.png"}
				};*/
			var resourceModel = IoC.Resolve<ResourceModel>();
			var cultures = resourceModel.GetUniqueCultureInfos().OrderBy(x => x.DisplayName);
			Cultures.AddRange(cultures.Select(x => new CultureItemViewModel { Value = x.Name, Text = x.NativeName.Split(new[] { " " },
                StringSplitOptions.RemoveEmptyEntries)[0].Split(new[] { "(" }, StringSplitOptions.RemoveEmptyEntries)[0], Image = string.Format("~/Content/images/lang_{0}_small.png", x.Name)
            }).OrderBy(c => c.Text));
		}
	}
}